/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// panimate.hpp - A simple graphic animation widget
//
// Author: Kenneth G. Maxwell
//
// Copyright (c) 1997-2005 Swell Software
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef _PEGANIMATE_
#define _PEGANIMATE_

typedef struct {
    PEGINT    BitmapId;
    PEGINT    Delay;
    PEGINT    xOffset;
    PEGINT    yOffset;
    PEGINT    Disposal;     // 2 = Back fill, 0/1 = nothing, 4 = write prev
} PegAnimationFrame;

#define DISPOSAL_BACK_FILL   2
#define DISPOSAL_PREV_FRAME  4


/*--------------------------------------------------------------------------*/
// PegAnimation mode values:
/*--------------------------------------------------------------------------*/
#define PEG_AF_WRAP      0x0001
#define PEG_AF_SHOWIDLE  0x0002
#define PEG_AF_AUTOSTART 0x0004

#define ANIMATION_TIMER  0x1000


/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class PegAnimation : public PegThing
{
    public:

        PegAnimation(const PegRect &Rect, PegAnimationFrame *pFrameList,
            PEGUSHORT Id = 0, PEGULONG Style = FF_NONE);

        PegAnimation(const PegRect &Rect, PEGUSHORT Id = 0,
            PEGULONG Style = FF_NONE);

        virtual ~PegAnimation(void);

        void AssignFrameList(PegAnimationFrame *pFrameList);

        virtual void Draw(const PegRect &Invalid);

        PEGINT GetCurrentFrame(void) {return mFrame;}

        virtual PEGINT Message(const PegMessage &Mesg);

        void SetCurrentFrame(PEGINT Frame);
        void SetMode(PEGUSHORT Mode);

        void Start(PEGINT Frame = -1);
        void Stop(void);

    protected:
        void InitializeFrameList(PegAnimationFrame *pFrames);

        PegAnimationFrame *mpCurrentFrame;
        PegAnimationFrame *mpFrameList;

        PEGINT mFrame;
        PEGBOOL mRunning;
        PEGUSHORT mMode;

};

#endif  // _PEGANIMATE_

// End of file
